import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { MessageVO, MessageForm, MessageQuery } from '@/api/zntx-app/message/types';

/**
 * 查询报警消息管理列表
 * @param query
 * @returns {*}
 */

export const listMessage = (query?: MessageQuery): AxiosPromise<MessageVO[]> => {
  return request({
    url: '/zntx-app/message/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询报警消息管理详细
 * @param id
 */
export const getMessage = (id: string | number): AxiosPromise<MessageVO> => {
  return request({
    url: '/zntx-app/message/' + id,
    method: 'get'
  });
};

/**
 * 设置消息已读
 * @param id
 */
export const readMessage = (id: string | number): AxiosPromise<MessageVO> => {
  return request({
    url: '/zntx-app/message/read/' + id,
    method: 'get'
  });
};
/**
 * 新增报警消息管理
 * @param data
 */
export const addMessage = (data: MessageForm) => {
  return request({
    url: '/zntx-app/message',
    method: 'post',
    data: data
  });
};

/**
 * 修改报警消息管理
 * @param data
 */
export const updateMessage = (data: MessageForm) => {
  return request({
    url: '/zntx-app/message',
    method: 'put',
    data: data
  });
};

/**
 * 删除报警消息管理
 * @param id
 */
export const delMessage = (id: string | number | Array<string | number>) => {
  return request({
    url: '/zntx-app/message/' + id,
    method: 'delete'
  });
};
